; Patrick Tessier
;1200x1600
; this script is used to test drag and drop Papyrus class diagram

;create element in the tree view

#include <library.au3>

Func DragAndDropTest()
	Opt("WinWaitDelay",100)
	Opt("WinTitleMatchMode",4)
	Opt("WinDetectHiddenText",1)
	Opt("MouseCoordMode",0)
	WinWait("Papyrus - umlExample1.di2 - Eclipse SDK","")	
	If Not WinActive("Papyrus - umlExample1.di2 - Eclipse SDK","") Then WinActivate("Papyrus - umlExample1.di2 - Eclipse SDK","")
	WinWaitActive("Papyrus - umlExample1.di2 - Eclipse SDK","")
	;open the tree view
	MouseMove(25,390)
	MouseDown("left")
	MouseUp("left")
	MouseMove(73,390)
	MouseDown("left")
	MouseUp("left")
	Sleep(500)
	createClass()
	createPackage()
	createProfile()
	CreatePrimitiveType()
	CreateDataType()
	CreateEnumeration()
	CreateComment()
	CreateConstraint()
	CreateInterface()
	createSignal()
	CreateInstanceSpecification()
	CreateOperationInClass()
	CreateOperationInClass()
	CreatePropertyInClass()
;~ 	dragAndDrop()
EndFunc

; use to open CreateMenu 
Func openCreateMenuSubElement()
	MouseMove(105,385)
	MouseDown("left")
	MouseUp("left")
	MouseDown("right")
	MouseUp("right")
	MouseMove(160,525)
	MouseDown("left")
	MouseUp("left")
	Sleep(500)
EndFunc

Func CreateOperationInClass()
	MouseMove(86,450)
	MouseDown("left")
	MouseUp("left")
	Sleep(500)
	MouseDown("right")
	MouseUp("right")
	MouseMove(165,590)
	MouseDown("left")
	MouseUp("left")
	Sleep(500)
	createElement(770)
	createElement(770)
	createElement(615)
EndFunc
Func CreatePropertyInClass()
	MouseMove(86,450)
	MouseDown("left")
	MouseUp("left")
	Sleep(500)
	MouseDown("right")
	MouseUp("right")
	MouseMove(165,590)
	MouseDown("left")
	MouseUp("left")
	Sleep(500)
	createElement(615)
EndFunc



Func createElement($posY)
	MouseMove(370,$posY)
	Sleep(500)
	MouseDown("left")
	MouseUp("left")
	Sleep(500)
EndFunc

Func createClass()
	openCreateMenuSubElement()
	createElement(1125)
EndFunc

Func createPackage()
	openCreateMenuSubElement()
	createElement(865)
EndFunc

Func createModel()
	openCreateMenuSubElement()
	createElement(645)
EndFunc

Func createProfile()
	openCreateMenuSubElement()
	createElement(585)
EndFunc 

Func createSignal()
	openCreateMenuSubElement()
	createElement(705)
EndFunc 
Func CreateInstanceSpecification()
	openCreateMenuSubElement()
	createElement(801)
	Send("{ESC}")
	Sleep(1000)
EndFunc

Func CreatePrimitiveType()
	openCreateMenuSubElement()
	createElement(485)
EndFunc

Func CreateDataType()
	openCreateMenuSubElement()
	createElement(925)
EndFunc

Func CreateEnumeration()
	openCreateMenuSubElement()
	createElement(785)
EndFunc

Func CreateComment()
	openCreateMenuSubElement()
	createElement(885)
EndFunc
Func CreateConstraint()
	openCreateMenuSubElement()
	createElement(1185)
EndFunc

Func CreateInterface()
		openCreateMenuSubElement()
	createElement(1005)
EndFunc

Func dragAndDrop()
	$TreeY=90
	For $i = 0 to 10 Step 1
		MouseMove($TreeY,400+$i*17)
		Sleep(1000)
		MouseDown("left")
		MouseMove(525,150)
		MouseUp("left")
		Sleep(1000)
		controlZ()
		controlY()
		controlZ()
	Next
endFunc
